import 'babel-polyfill'

// 如果你想用自己创建的实例，在自己单独的js文件里加上：let MOUNT_PATH="noNeed" / localStorage.setItem('MOUNT_PATH',MOUNT_PATH)
const MOUNT_PATH = localStorage.getItem('MOUNT_PATH')
console.log('VUE File:', MOUNT_PATH)

if (MOUNT_PATH === 'noNeed') {
  // 组件自己创建了实，将不会再引入下边的资源
  throw new Error("当前组件自己创建了实例,不会引用公用方法、实例");
}

import {
  beforeRouteEnter,
} from '@router/path'
if (!beforeRouteEnter())
  throw new Error("不允许访问");

import Vue from 'vue';
Vue.config.productionTip = false

import '@style_pc/basic'

import {
  Loading,
  Message, // 顶部消息提示
  MessageBox, // alert、confirm、prompt
} from 'element-ui'
Vue.use(Loading.directive);
Vue.prototype.$loading = Loading.service;
Vue.prototype.$msgbox = MessageBox;
Vue.prototype.$alert = MessageBox.alert;
Vue.prototype.$confirm = MessageBox.confirm;
Vue.prototype.$prompt = MessageBox.prompt;
Vue.prototype.$message = Message;

// 复制到粘贴板
import VueClipboard from 'vue-clipboard2'
VueClipboard.config.autoSetContainer = true
Vue.use(VueClipboard)

// 挂载js方法到vue
import {
  setPageTitle,
} from '@utils/utils'
import {
  getUrlParam,
  mergePageParams,
  goPageBack,
  goPage,
} from '@router/path'

setPageTitle()

Vue.prototype.$set_page_title = setPageTitle
Vue.prototype.$set_share = (params) => {}
Vue.prototype.$getUrlParam = getUrlParam
Vue.prototype.$mergePageParams = mergePageParams
Vue.prototype.$goPageBack = goPageBack
Vue.prototype.$goPage = goPage

// 动态捕获要挂载实例的.vue文件的路径
var App = resolve => require.ensure([], () => resolve(require("../src/views_pc/" + MOUNT_PATH + ".vue")));
new Vue({
  el: '#app',
  template: '<App/>',
  components: {
    App
  },
})